package com.free.semantic.common;

import java.util.HashMap;
import java.util.Map;

public class StructNode {

    private String value;

    private RangeObj rangeObj;

    //          来源事物     来源事物节点  对应的关系
    private Map<String, Pair<StructNode, RelationItem>> parent;

    //          目标事物     目标事物节点  对应的关系
    private Map<String, Pair<StructNode, RelationItem>> children;


    public StructNode(String objName) {
        this.value = objName;
        this.parent = new HashMap<>();
        this.children = new HashMap<>();
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public void addChildren(StructNode node, RelationItem item) {
        Pair<StructNode, RelationItem> pair = new Pair<>();
        pair.key = node;
        pair.value = item;
        children.put(node.value, pair);
    }

    public Map<String, StructNode> getChildrenMap() {
        Map<String, StructNode> result = new HashMap<>();
        if (children != null) {
            for (Map.Entry<String, Pair<StructNode, RelationItem>> pairEntry : children.entrySet()) {
                result.put(pairEntry.getKey(), pairEntry.getValue().key);
            }
        }
        return result;
    }

    public void addParent(StructNode node, RelationItem item) {
        Pair<StructNode, RelationItem> pair = new Pair<>();
        pair.key = node;
        pair.value = item;
        parent.put(node.value, pair);
    }

    public RangeObj getRangeObj() {
        return rangeObj;
    }

    public void setRangeObj(RangeObj rangeObj) {
        this.rangeObj = rangeObj;
    }

    public Map<String, Pair<StructNode, RelationItem>> getParent() {
        return parent;
    }

    public void setParent(Map<String, Pair<StructNode, RelationItem>> parent) {
        this.parent = parent;
    }

    public Map<String, Pair<StructNode, RelationItem>> getChildren() {
        return children;
    }

    public void setChildren(Map<String, Pair<StructNode, RelationItem>> children) {
        this.children = children;
    }

}
